package guda.shop.cms.manager.impl;

import guda.shop.cms.dao.ProductFashionDao;
import guda.shop.cms.entity.ProductFashion;
import guda.shop.cms.manager.CategoryMng;
import guda.shop.cms.manager.ProductFashionMng;
import guda.shop.cms.manager.StandardMng;
import guda.shop.common.hibernate3.Updater;
import guda.shop.common.image.ImageScale;
import guda.shop.common.page.Pagination;
import guda.shop.common.web.springmvc.RealPathResolver;
import guda.shop.core.manager.WebsiteMng;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ProductFashionMngImpl
        implements ProductFashionMng {

    @Autowired
    private ProductFashionDao productFashionDao;

    @Autowired
    private WebsiteMng websiteMng;

    @Autowired
    private RealPathResolver realPathResolver;

    @Autowired
    private CategoryMng categoryMng;

    @Autowired
    private ImageScale imageScale;

    @Autowired
    private StandardMng standardMng;

    public ProductFashion deleteById(Long paramLong) {
        return this.productFashionDao.deleteById(paramLong);
    }

    public ProductFashion[] deleteByIds(Long[] paramArrayOfLong) {
        ProductFashion[] arrayOfProductFashion = new ProductFashion[paramArrayOfLong.length];
        int i = 0;
        int j = paramArrayOfLong.length;
        while (i < j) {
            arrayOfProductFashion[i] = deleteById(paramArrayOfLong[i]);
            i++;
        }
        return arrayOfProductFashion;
    }

    public ProductFashion findById(Long paramLong) {
        return this.productFashionDao.findById(paramLong);
    }

    public List<ProductFashion> findByProductId(Long paramLong) {
        return this.productFashionDao.findByProductId(paramLong);
    }

    public Pagination getPage(Long paramLong, int paramInt1, int paramInt2) {
        return this.productFashionDao.getPage(paramLong, paramInt1, paramInt2);
    }

    public ProductFashion save(ProductFashion paramProductFashion, String[] paramArrayOfString) {
        String str1 = "";
        for (String str2 : paramArrayOfString)
            str1 = str1 + " " + this.standardMng.findById(Long.valueOf(Long.parseLong(str2))).getName();
        paramProductFashion.setAttitude(str1);
        paramProductFashion.init();
        return this.productFashionDao.save(paramProductFashion);
    }

    public void addStandard(ProductFashion paramProductFashion, String[] paramArrayOfString) {
        for (String str : paramArrayOfString)
            paramProductFashion.addTostandards(this.standardMng.findById(Long.valueOf(Long.parseLong(str))));
    }

    public void updateStandard(ProductFashion paramProductFashion, String[] paramArrayOfString) {
        paramProductFashion.getStandards().clear();
        for (String str : paramArrayOfString)
            paramProductFashion.addTostandards(this.standardMng.findById(Long.valueOf(Long.parseLong(str))));
    }

    public void deleteImage(ProductFashion paramProductFashion, String paramString) {
    }

    public ProductFashion update(ProductFashion paramProductFashion, String[] paramArrayOfString) {
        String str1 = "";
        for (String str2 : paramArrayOfString)
            str1 = str1 + " " + this.standardMng.findById(Long.valueOf(Long.parseLong(str2))).getName();
        paramProductFashion.setAttitude(str1);
        Updater updater = new Updater(paramProductFashion);
        ProductFashion localProductFashion = this.productFashionDao.updateByUpdater(updater);
        return localProductFashion;
    }

    public ProductFashion update(ProductFashion paramProductFashion) {
        Updater localUpdater = new Updater(paramProductFashion);
        ProductFashion localProductFashion = this.productFashionDao.updateByUpdater(localUpdater);
        return localProductFashion;
    }

    public Pagination productLack(Integer paramInteger1, Integer paramInteger2, int paramInt1, int paramInt2) {
        return this.productFashionDao.productLack(paramInteger1, paramInteger2, paramInt1, paramInt2);
    }

    public Integer productLackCount(Integer paramInteger1, Integer paramInteger2) {
        return this.productFashionDao.productLackCount(paramInteger1, paramInteger2);
    }

    public Pagination getSaleTopPage(int paramInt1, int paramInt2) {
        return this.productFashionDao.getSaleTopPage(paramInt1, paramInt2);
    }

    public Boolean getOneFash(Long paramLong) {
        return this.productFashionDao.getOneFashion(paramLong);
    }
}

